#include <iostream>
using namespace std;

int find_num(int n)
{
    int count = 0;
    int sum = 0;
    for(int i = 2;i <= n;i++)//效率不高
    {
        sum = 0;
        for(int j = 1;j < i; ++j)
        {
            if(i % j == 0)//对约数求和
                sum += j;
        }
        if(sum == i)
            count++;
    }
    return count;
}

int main()
{
    int n;
    int count;
    while(cin >> n)
    {
        count = find_num(n);
        cout << count << endl;
    }
    return 0;
}
